#pragma once

#include "dispatcher.hpp"
#include "endpoint.hpp"

class TcpServer
{
public:
    TcpServer(Dispatcher& d) : dispatcher(d) {}
    ~TcpServer() { sock.Close(); }
    void Start(const EndPoint& local);
private:
    void ConnEstabilished(const Socket& sock);
    void HandleMessage(const Socket& sock);

    Dispatcher& dispatcher;
    Socket sock;
};